package com.controller;

import com.dto.excution.ListExcution;
import com.entity.AppraiseInfo;
import com.enums.ListEnum;
import com.service.AppraiseService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/appraise")
public class AppraiseController {

    @Autowired
    private AppraiseService appraiseService;

    @ApiOperation(value = "评价")
    @PostMapping(value = "/insertAppraise")
    @ResponseBody
    public ListExcution<Void> insertAppraise(Integer recordId,Integer type,Integer sendUserId,Integer getUserId,Integer appraiseNum,Integer serviceAttitude,Integer teachingQuality,Double average,Integer num,String appraiseContent){
       int AppraiseCount=appraiseService.insertAppraise(recordId,type,sendUserId,getUserId,appraiseNum,serviceAttitude,teachingQuality,average,num,appraiseContent);
       if(AppraiseCount>0){
           return  new ListExcution<Void>(null, ListEnum.SUCCESS);
       }else {
           return  new ListExcution<Void>(null, ListEnum.FAIL);
       }
    }


    @ApiOperation(value = "查看评价1.好评2.中评3.差评")
    @PostMapping(value = "/LookAppraise")
    @ResponseBody
    public List<AppraiseInfo> LookAppraise(Integer type, Integer getUserId,Integer limit){
        List<AppraiseInfo> appraiseInfo=appraiseService.LookAppraise(type,getUserId,limit);
        return appraiseInfo;
    }

    @ApiOperation(value = "隐藏/显示简历0隐藏1显示")
    @PostMapping(value = "/showHiddenResume")
    @ResponseBody
    public ListExcution<Void> showHiddenResume(Integer type,Integer userId){
        int showHidden=appraiseService.showHiddenResume(type ,userId);
        if(showHidden>0){
            return new ListExcution<Void>(null,ListEnum.SUCCESS);
        }else {
            return new ListExcution<Void>(null,ListEnum.FAIL);
        }
    }

    @ApiOperation(value = "查看是否评价")
    @PostMapping(value = "/LookIsAppraise")
    @ResponseBody
    public ListExcution<Void> LookIsAppraise(Integer recordId){
        int count =appraiseService.LookIsAppraise(recordId);
        if(count > 0){
            return new ListExcution<Void>(null,ListEnum.YESAPP);
        }else{
            return new ListExcution<Void>(null,ListEnum.NOAPP);
        }
    }

}
